{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports\n",
    "\n",
    "Import all the modules and functionalities we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "# Import standard libraries.\n",
    "import os\n",
    "\n",
    "# Import third party libraries.\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from statsmodels.stats.multitest import multipletests\n",
    "from statsmodels.stats.proportion import proportions_ztest\n",
    "\n",
    "# Import custom libraries/scripts.\n",
    "import annotations\n",
    "import helpers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Loading data\n",
    "\n",
    "Fetch all our relevant data for the current analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set working contants.\n",
    "EXPERIMENTS_PATH = r'D:\\Miguel\\PhD\\Results\\Competition\\DL\\small_arenas\\Ir84a\\silencing\\crossed_with_white_minus\\processed\\food'\n",
    "FPS = 60\n",
    "N_MINUTES = 5\n",
    "N_FRAMES = N_MINUTES * 60 * FPS # First five minutes of copulation.\n",
    "INK = 'black'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set figure configurations.\n",
    "sns.set(\n",
    "        context='paper',\n",
    "        style='ticks',\n",
    "        font='sans-serif',\n",
    "        font_scale=1.0, \n",
    "        rc={\n",
    "            'axes.axisbelow': True,\n",
    "            'axes.edgecolor': INK,\n",
    "            'axes.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'axes.grid': False,\n",
    "            'axes.labelcolor': INK,\n",
    "            'axes.labelsize': 13.0,\n",
    "            'axes.labelweight': 'normal',\n",
    "            'axes.linewidth': 1.0,\n",
    "            'axes.spines.left': True,\n",
    "            'axes.spines.bottom': True,\n",
    "            'axes.spines.top': False,\n",
    "            'axes.spines.right': False,\n",
    "            'axes.titlepad': 15.0,\n",
    "            'axes.titlesize': 20.0,\n",
    "            'axes.titleweight': 'bold',\n",
    "            'figure.facecolor': 'white' if INK=='black' else 'black',\n",
    "            'figure.figsize': [4.0, 4.0],\n",
    "            'figure.titlesize': 30.0,\n",
    "            'figure.titleweight': 'bold',\n",
    "            'font.family': ['sans-serif'],\n",
    "            'font.sans-serif': ['Arial'],\n",
    "            'legend.frameon': False,\n",
    "            'legend.fontsize': 11.0,\n",
    "            'lines.color': INK,\n",
    "            'lines.linewidth': 1.0,\n",
    "            'patch.edgecolor': INK,\n",
    "            'savefig.dpi': 300,\n",
    "            'savefig.format': 'png',\n",
    "            'savefig.bbox': 'tight',\n",
    "            'savefig.transparent': True,\n",
    "            'text.color': INK,\n",
    "            'text.usetex': False,\n",
    "            'xtick.color': INK,\n",
    "            'xtick.direction': 'out',\n",
    "            'xtick.labelsize': 12.0,\n",
    "            'xtick.major.pad': 5.0,\n",
    "            'xtick.major.size': 0.0,\n",
    "            'xtick.major.width': 1.0,\n",
    "            'xtick.minor.size': 0.0,\n",
    "            'xtick.minor.width': 0.4,\n",
    "            'ytick.color': INK,\n",
    "            'ytick.direction': 'out',\n",
    "            'ytick.labelsize': 12.0,\n",
    "            'ytick.major.pad': 5.0,\n",
    "            'ytick.major.size': 3.0,\n",
    "            'ytick.major.width': 1.0,\n",
    "            'ytick.minor.size': 0.0,\n",
    "            'ytick.minor.width': 0.4\n",
    "           }\n",
    "       )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Folder already exists, skipping.\n"
     ]
    }
   ],
   "source": [
    "# Prepare the Figures folder to save our graphs in.\n",
    "savepath = os.path.join(r'C:\\Users\\Miguel\\Desktop\\paper_data', 'paper_figures', 'figureS3')\n",
    "try:\n",
    "    os.makedirs(savepath)\n",
    "    print(\"New folder created.\")\n",
    "except FileExistsError:\n",
    "    print(\"Folder already exists, skipping.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paths to conditions:\n",
      " ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control', 'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test', 'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control']\n"
     ]
    }
   ],
   "source": [
    "# Set the conditions to analyze.\n",
    "condition_order = ['gal4_control', 'uas_control', 'test']\n",
    "conditions = [item.path for item in os.scandir(EXPERIMENTS_PATH) if item.name in condition_order]\n",
    "print('Paths to conditions:\\n', conditions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t\n",
      " gal4_control\n",
      "Copulation too short: video_2021-02-10T10_24_13_arena2.csv\n",
      "\t\n",
      " test\n",
      "Copulation too short: video_2021-02-11T11_11_10_arena6.csv\n",
      "\t\n",
      " uas_control\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-05T11_39_22_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-05T11_39_22_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-05T12_16_51_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-08T10_00_51_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-08T10_00_51_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-08T12_06_28_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-08T12_06_28_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-08T12_38_30_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-09T10_34_50_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-09T10_34_50_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-09T11_16_40_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-09T11_16_40_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-09T12_02_10_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-09T12_42_06_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T10_24_13_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T10_24_13_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T11_04_44_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T11_04_44_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T11_04_44_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T11_43_39_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T11_43_39_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T11_43_39_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T12_20_42_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T12_20_42_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-10T12_20_42_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-11T10_24_57_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-11T10_24_57_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-11T10_24_57_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-11T10_24_57_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-11T11_11_10_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-11T11_58_28_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\gal4_control\\\\video_2021-02-11T11_58_28_arena7.csv'],\n",
       " 'uas_control': ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-05T11_39_22_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-05T12_16_51_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-05T12_16_51_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-08T10_00_51_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-08T10_00_51_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-08T12_06_28_arena4.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-08T12_06_28_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-08T12_38_30_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-08T12_38_30_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-08T12_38_30_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-09T11_16_40_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-09T11_16_40_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-09T12_02_10_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-09T12_02_10_arena9.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-09T12_42_06_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-09T12_42_06_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-10T10_24_13_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-10T11_04_44_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-10T11_43_39_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-10T11_43_39_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-10T12_20_42_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T10_24_57_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T10_24_57_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T11_11_10_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T11_11_10_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T11_11_10_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T11_58_28_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T11_58_28_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\uas_control\\\\video_2021-02-11T11_58_28_arena8.csv'],\n",
       " 'test': ['D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-05T11_39_22_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-05T11_39_22_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-05T11_39_22_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-05T11_39_22_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-05T12_16_51_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T10_00_51_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T10_00_51_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T10_00_51_arena7.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T10_00_51_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T12_06_28_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T12_06_28_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T12_38_30_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T12_38_30_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-08T12_38_30_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T10_34_50_arena3.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T11_16_40_arena10.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T11_16_40_arena5.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T12_02_10_arena12.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T12_02_10_arena14.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T12_02_10_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T12_42_06_arena11.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T12_42_06_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-09T12_42_06_arena2.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-10T10_24_13_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-10T10_24_13_arena6.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-10T11_04_44_arena15.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-10T11_43_39_arena8.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-10T12_20_42_arena13.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-11T10_24_57_arena16.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-11T11_11_10_arena1.csv',\n",
       "  'D:\\\\Miguel\\\\PhD\\\\Results\\\\Competition\\\\DL\\\\small_arenas\\\\Ir84a\\\\silencing\\\\crossed_with_white_minus\\\\processed\\\\food\\\\test\\\\video_2021-02-11T11_58_28_arena4.csv']}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load all usable experiments for each condition.\n",
    "experiments = {condition: [] for condition in condition_order}\n",
    "\n",
    "for condition_path in conditions:\n",
    "    \n",
    "    condition = os.path.basename(condition_path)\n",
    "    print('\\t\\n', condition)\n",
    "    \n",
    "    for item in os.scandir(condition_path):\n",
    "        if item.name.endswith('.csv'):\n",
    "            \n",
    "            annotation_video = annotations.read(item.path)\n",
    "\n",
    "            try:\n",
    "                copulation = annotation_video[0].events[0]\n",
    "                \n",
    "                # Filter out videos where copulation is interrupted.\n",
    "                copulation_end = copulation.time_interval[1]\n",
    "                if copulation_end==N_FRAMES:\n",
    "                    if copulatio.duration < 5 * 60 * FPS:\n",
    "                        print('Copulation interrupted:', item.name)\n",
    "                        continue\n",
    "\n",
    "                # Filter out videos where copulation lasts less than 8 minutes.\n",
    "                copulation_duration = copulation.duration\n",
    "                if copulation_duration <= 8 * 60 * FPS:\n",
    "                    print('Copulation too short:', item.name)\n",
    "                    continue\n",
    "            \n",
    "            except IndexError:\n",
    "                continue\n",
    "            \n",
    "            experiments[condition].append(item.path)\n",
    "\n",
    "experiments"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Aggression Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 0 \n",
      "Experiment: video_2021-02-05T11_39_22_arena2.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-05T11_39_22_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-05T12_16_51_arena10.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-08T10_00_51_arena12.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-08T10_00_51_arena15.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-08T12_06_28_arena2.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-08T12_06_28_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-08T12_38_30_arena16.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-09T10_34_50_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-09T10_34_50_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-09T11_16_40_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-09T11_16_40_arena2.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-09T12_02_10_arena13.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-09T12_42_06_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-10T10_24_13_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-10T10_24_13_arena8.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-10T11_04_44_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-10T11_04_44_arena12.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-10T11_04_44_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-10T11_43_39_arena3.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-10T11_43_39_arena4.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-02-10T11_43_39_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-02-10T12_20_42_arena10.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-02-10T12_20_42_arena5.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-02-10T12_20_42_arena6.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-02-11T10_24_57_arena11.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-02-11T10_24_57_arena13.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-02-11T10_24_57_arena14.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-02-11T10_24_57_arena15.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2021-02-11T11_11_10_arena9.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2021-02-11T11_58_28_arena1.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 31 \n",
      "Experiment: video_2021-02-11T11_58_28_arena7.csv \n",
      "Condition: gal4_control \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2021-02-05T11_39_22_arena4.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-05T12_16_51_arena15.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-05T12_16_51_arena9.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-08T10_00_51_arena3.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-08T10_00_51_arena4.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-08T12_06_28_arena4.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-08T12_06_28_arena6.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-08T12_38_30_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-08T12_38_30_arena3.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-08T12_38_30_arena7.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-09T11_16_40_arena1.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-09T11_16_40_arena9.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-09T12_02_10_arena15.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-09T12_02_10_arena9.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-09T12_42_06_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-09T12_42_06_arena15.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-10T10_24_13_arena5.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-10T11_04_44_arena13.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-10T11_43_39_arena11.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-10T11_43_39_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-10T12_20_42_arena1.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-02-11T10_24_57_arena10.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-02-11T10_24_57_arena12.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-02-11T11_11_10_arena10.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-02-11T11_11_10_arena13.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-02-11T11_11_10_arena14.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-02-11T11_58_28_arena3.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-02-11T11_58_28_arena6.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-02-11T11_58_28_arena8.csv \n",
      "Condition: uas_control \n",
      "\n",
      "Iteration: 0 \n",
      "Experiment: video_2021-02-05T11_39_22_arena1.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 1 \n",
      "Experiment: video_2021-02-05T11_39_22_arena3.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 2 \n",
      "Experiment: video_2021-02-05T11_39_22_arena7.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 3 \n",
      "Experiment: video_2021-02-05T11_39_22_arena8.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 4 \n",
      "Experiment: video_2021-02-05T12_16_51_arena13.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 5 \n",
      "Experiment: video_2021-02-08T10_00_51_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 6 \n",
      "Experiment: video_2021-02-08T10_00_51_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 7 \n",
      "Experiment: video_2021-02-08T10_00_51_arena7.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 8 \n",
      "Experiment: video_2021-02-08T10_00_51_arena8.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 9 \n",
      "Experiment: video_2021-02-08T12_06_28_arena3.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 10 \n",
      "Experiment: video_2021-02-08T12_06_28_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 11 \n",
      "Experiment: video_2021-02-08T12_38_30_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 12 \n",
      "Experiment: video_2021-02-08T12_38_30_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 13 \n",
      "Experiment: video_2021-02-08T12_38_30_arena8.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 14 \n",
      "Experiment: video_2021-02-09T10_34_50_arena3.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 15 \n",
      "Experiment: video_2021-02-09T11_16_40_arena10.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 16 \n",
      "Experiment: video_2021-02-09T11_16_40_arena5.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 17 \n",
      "Experiment: video_2021-02-09T12_02_10_arena12.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 18 \n",
      "Experiment: video_2021-02-09T12_02_10_arena14.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 19 \n",
      "Experiment: video_2021-02-09T12_02_10_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 20 \n",
      "Experiment: video_2021-02-09T12_42_06_arena11.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 21 \n",
      "Experiment: video_2021-02-09T12_42_06_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 22 \n",
      "Experiment: video_2021-02-09T12_42_06_arena2.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 23 \n",
      "Experiment: video_2021-02-10T10_24_13_arena1.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 24 \n",
      "Experiment: video_2021-02-10T10_24_13_arena6.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 25 \n",
      "Experiment: video_2021-02-10T11_04_44_arena15.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 26 \n",
      "Experiment: video_2021-02-10T11_43_39_arena8.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 27 \n",
      "Experiment: video_2021-02-10T12_20_42_arena13.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 28 \n",
      "Experiment: video_2021-02-11T10_24_57_arena16.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 29 \n",
      "Experiment: video_2021-02-11T11_11_10_arena1.csv \n",
      "Condition: test \n",
      "\n",
      "Iteration: 30 \n",
      "Experiment: video_2021-02-11T11_58_28_arena4.csv \n",
      "Condition: test \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>aggression_latency</th>\n",
       "      <th>aggression_latency_mins</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>1130.0</td>\n",
       "      <td>0.313889</td>\n",
       "      <td>336</td>\n",
       "      <td>7</td>\n",
       "      <td>0.018667</td>\n",
       "      <td>1.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-05T11_39_22_arena2.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>3699.0</td>\n",
       "      <td>1.027500</td>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>0.001056</td>\n",
       "      <td>0.6</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-05T11_39_22_arena6.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>3386.0</td>\n",
       "      <td>0.940556</td>\n",
       "      <td>17</td>\n",
       "      <td>5</td>\n",
       "      <td>0.000944</td>\n",
       "      <td>1.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-05T12_16_51_arena10.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>2771.0</td>\n",
       "      <td>0.769722</td>\n",
       "      <td>242</td>\n",
       "      <td>4</td>\n",
       "      <td>0.013444</td>\n",
       "      <td>0.8</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-08T10_00_51_arena12.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-08T10_00_51_arena15.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>True</td>\n",
       "      <td>915.0</td>\n",
       "      <td>0.254167</td>\n",
       "      <td>77</td>\n",
       "      <td>30</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>6.0</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-10T11_43_39_arena8.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>True</td>\n",
       "      <td>466.0</td>\n",
       "      <td>0.129444</td>\n",
       "      <td>23</td>\n",
       "      <td>4</td>\n",
       "      <td>0.001278</td>\n",
       "      <td>0.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-10T12_20_42_arena13.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>True</td>\n",
       "      <td>5506.0</td>\n",
       "      <td>1.529444</td>\n",
       "      <td>278</td>\n",
       "      <td>9</td>\n",
       "      <td>0.015444</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-11T10_24_57_arena16.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>True</td>\n",
       "      <td>467.0</td>\n",
       "      <td>0.129722</td>\n",
       "      <td>443</td>\n",
       "      <td>9</td>\n",
       "      <td>0.024611</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-11T11_11_10_arena1.csv</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>True</td>\n",
       "      <td>235.0</td>\n",
       "      <td>0.065278</td>\n",
       "      <td>142</td>\n",
       "      <td>4</td>\n",
       "      <td>0.007889</td>\n",
       "      <td>0.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-11T11_58_28_arena4.csv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>92 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  aggression_latency  aggression_latency_mins  nframes  \\\n",
       "0             True              1130.0                 0.313889      336   \n",
       "1             True              3699.0                 1.027500       19   \n",
       "2             True              3386.0                 0.940556       17   \n",
       "3             True              2771.0                 0.769722      242   \n",
       "4            False                 NaN                 0.000000        0   \n",
       "..             ...                 ...                      ...      ...   \n",
       "87            True               915.0                 0.254167       77   \n",
       "88            True               466.0                 0.129444       23   \n",
       "89            True              5506.0                 1.529444      278   \n",
       "90            True               467.0                 0.129722      443   \n",
       "91            True               235.0                 0.065278      142   \n",
       "\n",
       "    nbouts  ratio_frames  ratio_bouts     condition  \\\n",
       "0        7      0.018667          1.4  gal4_control   \n",
       "1        3      0.001056          0.6  gal4_control   \n",
       "2        5      0.000944          1.0  gal4_control   \n",
       "3        4      0.013444          0.8  gal4_control   \n",
       "4        0      0.000000          0.0  gal4_control   \n",
       "..     ...           ...          ...           ...   \n",
       "87      30      0.004278          6.0          test   \n",
       "88       4      0.001278          0.8          test   \n",
       "89       9      0.015444          1.8          test   \n",
       "90       9      0.024611          1.8          test   \n",
       "91       4      0.007889          0.8          test   \n",
       "\n",
       "                               experiment  \n",
       "0    video_2021-02-05T11_39_22_arena2.csv  \n",
       "1    video_2021-02-05T11_39_22_arena6.csv  \n",
       "2   video_2021-02-05T12_16_51_arena10.csv  \n",
       "3   video_2021-02-08T10_00_51_arena12.csv  \n",
       "4   video_2021-02-08T10_00_51_arena15.csv  \n",
       "..                                    ...  \n",
       "87   video_2021-02-10T11_43_39_arena8.csv  \n",
       "88  video_2021-02-10T12_20_42_arena13.csv  \n",
       "89  video_2021-02-11T10_24_57_arena16.csv  \n",
       "90   video_2021-02-11T11_11_10_arena1.csv  \n",
       "91   video_2021-02-11T11_58_28_arena4.csv  \n",
       "\n",
       "[92 rows x 9 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aggression_df = pd.DataFrame()\n",
    "for condition in condition_order:\n",
    "    for h, experiment_path in enumerate(experiments[condition]):\n",
    "\n",
    "        experiment = os.path.basename(experiment_path)\n",
    "        \n",
    "        print('Iteration:', h, '\\nExperiment:', experiment, '\\nCondition:', condition, '\\n')\n",
    "        \n",
    "        # Exclude experiments without copulation (since aggression is only observed during copulation).\n",
    "        annotation_video = annotations.read(experiment_path)\n",
    "        try:\n",
    "            copulation = annotation_video[0].events[0]\n",
    "        except IndexError:\n",
    "            continue\n",
    "        \n",
    "        aggression_events = list(filter(lambda event: event.time < (copulation.time + N_FRAMES), annotation_video[1].events)) # Consider aggression only during the first 5 minutes of copulation.\n",
    "        n_events = len(aggression_events)\n",
    "\n",
    "        # In case there is aggression, do the necessary calculations.\n",
    "        if n_events > 0:\n",
    "            aggression_latency =  aggression_events[0].time - copulation.time\n",
    "            aggression_latency_mins = aggression_latency / (60 * FPS)\n",
    "            ratio_frames = sum([aggression.duration for aggression in aggression_events]) / N_FRAMES\n",
    "            ratio_bouts = n_events / N_MINUTES\n",
    "\n",
    "            aggression_data = pd.DataFrame({'has_aggression': True,\n",
    "                                            'aggression_latency': aggression_latency,\n",
    "                                            'aggression_latency_mins': aggression_latency_mins,\n",
    "                                            'nframes': sum([aggression.duration for aggression in aggression_events]),\n",
    "                                            'nbouts': n_events,\n",
    "                                            'ratio_frames': ratio_frames,\n",
    "                                            'ratio_bouts': ratio_bouts,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "\n",
    "        # If not, preset our dictionary with default values.\n",
    "        else:\n",
    "            aggression_data = pd.DataFrame({'has_aggression': False,\n",
    "                                            'aggression_latency': np.nan,\n",
    "                                            'aggression_latency_mins': 0,\n",
    "                                            'nframes': 0,\n",
    "                                            'nbouts': 0,\n",
    "                                            'ratio_frames': 0, \n",
    "                                            'ratio_bouts': 0,\n",
    "                                            'condition': condition,\n",
    "                                            'experiment': experiment},\n",
    "                                            index=[h],\n",
    "                                           )\n",
    "        \n",
    "        # Concatenate all data together.\n",
    "        aggression_df = pd.concat([aggression_df, aggression_data], ignore_index=True)\n",
    "\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Outlier Detection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t gal4_control \n",
      "\n",
      "[6]\n",
      "Number data points considered outliers: 1\n",
      "Percent data points considered outliers: 3.125 %\n",
      "\n",
      "\t uas_control \n",
      "\n",
      "[]\n",
      "Number data points considered outliers: 0\n",
      "Percent data points considered outliers: 0.0 %\n",
      "\n",
      "\t test \n",
      "\n",
      "[]\n",
      "Number data points considered outliers: 0\n",
      "Percent data points considered outliers: 0.0 %\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>has_aggression</th>\n",
       "      <th>aggression_latency</th>\n",
       "      <th>aggression_latency_mins</th>\n",
       "      <th>nframes</th>\n",
       "      <th>nbouts</th>\n",
       "      <th>ratio_frames</th>\n",
       "      <th>ratio_bouts</th>\n",
       "      <th>condition</th>\n",
       "      <th>experiment</th>\n",
       "      <th>author</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>1130.0</td>\n",
       "      <td>0.313889</td>\n",
       "      <td>336</td>\n",
       "      <td>7</td>\n",
       "      <td>0.018667</td>\n",
       "      <td>1.4</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-05T11_39_22_arena2.csv</td>\n",
       "      <td>Cecilia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>3699.0</td>\n",
       "      <td>1.027500</td>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>0.001056</td>\n",
       "      <td>0.6</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-05T11_39_22_arena6.csv</td>\n",
       "      <td>Cecilia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>3386.0</td>\n",
       "      <td>0.940556</td>\n",
       "      <td>17</td>\n",
       "      <td>5</td>\n",
       "      <td>0.000944</td>\n",
       "      <td>1.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-05T12_16_51_arena10.csv</td>\n",
       "      <td>Cecilia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>2771.0</td>\n",
       "      <td>0.769722</td>\n",
       "      <td>242</td>\n",
       "      <td>4</td>\n",
       "      <td>0.013444</td>\n",
       "      <td>0.8</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-08T10_00_51_arena12.csv</td>\n",
       "      <td>Cecilia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>gal4_control</td>\n",
       "      <td>video_2021-02-08T10_00_51_arena15.csv</td>\n",
       "      <td>Cecilia</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>True</td>\n",
       "      <td>915.0</td>\n",
       "      <td>0.254167</td>\n",
       "      <td>77</td>\n",
       "      <td>30</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>6.0</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-10T11_43_39_arena8.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>True</td>\n",
       "      <td>466.0</td>\n",
       "      <td>0.129444</td>\n",
       "      <td>23</td>\n",
       "      <td>4</td>\n",
       "      <td>0.001278</td>\n",
       "      <td>0.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-10T12_20_42_arena13.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>True</td>\n",
       "      <td>5506.0</td>\n",
       "      <td>1.529444</td>\n",
       "      <td>278</td>\n",
       "      <td>9</td>\n",
       "      <td>0.015444</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-11T10_24_57_arena16.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>True</td>\n",
       "      <td>467.0</td>\n",
       "      <td>0.129722</td>\n",
       "      <td>443</td>\n",
       "      <td>9</td>\n",
       "      <td>0.024611</td>\n",
       "      <td>1.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-11T11_11_10_arena1.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>True</td>\n",
       "      <td>235.0</td>\n",
       "      <td>0.065278</td>\n",
       "      <td>142</td>\n",
       "      <td>4</td>\n",
       "      <td>0.007889</td>\n",
       "      <td>0.8</td>\n",
       "      <td>test</td>\n",
       "      <td>video_2021-02-11T11_58_28_arena4.csv</td>\n",
       "      <td>Sophie</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>91 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    has_aggression  aggression_latency  aggression_latency_mins  nframes  \\\n",
       "0             True              1130.0                 0.313889      336   \n",
       "1             True              3699.0                 1.027500       19   \n",
       "2             True              3386.0                 0.940556       17   \n",
       "3             True              2771.0                 0.769722      242   \n",
       "4            False                 NaN                 0.000000        0   \n",
       "..             ...                 ...                      ...      ...   \n",
       "87            True               915.0                 0.254167       77   \n",
       "88            True               466.0                 0.129444       23   \n",
       "89            True              5506.0                 1.529444      278   \n",
       "90            True               467.0                 0.129722      443   \n",
       "91            True               235.0                 0.065278      142   \n",
       "\n",
       "    nbouts  ratio_frames  ratio_bouts     condition  \\\n",
       "0        7      0.018667          1.4  gal4_control   \n",
       "1        3      0.001056          0.6  gal4_control   \n",
       "2        5      0.000944          1.0  gal4_control   \n",
       "3        4      0.013444          0.8  gal4_control   \n",
       "4        0      0.000000          0.0  gal4_control   \n",
       "..     ...           ...          ...           ...   \n",
       "87      30      0.004278          6.0          test   \n",
       "88       4      0.001278          0.8          test   \n",
       "89       9      0.015444          1.8          test   \n",
       "90       9      0.024611          1.8          test   \n",
       "91       4      0.007889          0.8          test   \n",
       "\n",
       "                               experiment   author  \n",
       "0    video_2021-02-05T11_39_22_arena2.csv  Cecilia  \n",
       "1    video_2021-02-05T11_39_22_arena6.csv  Cecilia  \n",
       "2   video_2021-02-05T12_16_51_arena10.csv  Cecilia  \n",
       "3   video_2021-02-08T10_00_51_arena12.csv  Cecilia  \n",
       "4   video_2021-02-08T10_00_51_arena15.csv  Cecilia  \n",
       "..                                    ...      ...  \n",
       "87   video_2021-02-10T11_43_39_arena8.csv   Sophie  \n",
       "88  video_2021-02-10T12_20_42_arena13.csv   Sophie  \n",
       "89  video_2021-02-11T10_24_57_arena16.csv   Sophie  \n",
       "90   video_2021-02-11T11_11_10_arena1.csv   Sophie  \n",
       "91   video_2021-02-11T11_58_28_arena4.csv   Sophie  \n",
       "\n",
       "[91 rows x 10 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corrected_ratio_frames = pd.DataFrame()\n",
    "\n",
    "for condition in condition_order:\n",
    "\n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        dataset = aggression_df.query('condition==\"' + condition + '\"')['ratio_frames']\n",
    "\n",
    "        outlier_positions = helpers.check_outliers(dataset)\n",
    "        print(outlier_positions)\n",
    "\n",
    "        fresh_dataset = pd.DataFrame(helpers.remove_outliers(dataset, indices=outlier_positions))\n",
    "        fresh_dataset['condition'] = condition\n",
    "\n",
    "        corrected_ratio_frames = pd.concat([corrected_ratio_frames, fresh_dataset], axis=0)\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "\n",
    "aggression_df = aggression_df.loc[corrected_ratio_frames.index]\n",
    "aggression_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Aggression Bouts / Min."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>condition</th>\n",
       "      <th>ratio_bouts</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>1.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>gal4_control</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>test</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>test</td>\n",
       "      <td>0.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>test</td>\n",
       "      <td>1.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>test</td>\n",
       "      <td>1.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>test</td>\n",
       "      <td>0.8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>91 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       condition  ratio_bouts\n",
       "0   gal4_control          1.4\n",
       "1   gal4_control          0.6\n",
       "2   gal4_control          1.0\n",
       "3   gal4_control          0.8\n",
       "4   gal4_control          0.0\n",
       "..           ...          ...\n",
       "87          test          6.0\n",
       "88          test          0.8\n",
       "89          test          1.8\n",
       "90          test          1.8\n",
       "91          test          0.8\n",
       "\n",
       "[91 rows x 2 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_df = aggression_df.copy()[['condition', 'ratio_bouts']]\n",
    "ratio_bouts_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t gal4_control \n",
      "\n",
      "Shapiro's Test: group 1 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 1 IS NOT normally distributed.\n",
      "Shapiro's Test: group 2 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 2 IS NOT normally distributed.\n",
      "Levene's Test for non-normally distributed samples:\n",
      "  p-value = 0.332966\n",
      "  All groups were sampled from populations with IDENTICAL variances.\n",
      "\n",
      "Mann-Whitney p-value: 0.08629421234185297 \n",
      "\n",
      "\n",
      "\t uas_control \n",
      "\n",
      "Shapiro's Test: group 1 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 1 IS NOT normally distributed.\n",
      "Shapiro's Test: group 2 IS NOT normally distributed.\n",
      "D'Agostino's Test: group 2 IS NOT normally distributed.\n",
      "Levene's Test for non-normally distributed samples:\n",
      "  p-value = 0.465598\n",
      "  All groups were sampled from populations with IDENTICAL variances.\n",
      "\n",
      "Mann-Whitney p-value: 0.20526516919739457 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': 0.08629421234185297, 'uas_control': 0.20526516919739457}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_pvalues = {}\n",
    "\n",
    "test = ratio_bouts_df.query('condition==\"test\"')['ratio_bouts']\n",
    "\n",
    "for condition in condition_order[:-1]:\n",
    "        \n",
    "    print('\\n\\t', condition, '\\n')\n",
    "\n",
    "    try:\n",
    "        control = ratio_bouts_df.query('condition==\"' + condition + '\"')['ratio_bouts']\n",
    "\n",
    "        temp_values = {'control': control, 'test': test}\n",
    "\n",
    "        pvalue_condition = helpers.run_statistics(temp_values)\n",
    "\n",
    "        ratio_bouts_pvalues[condition] = pvalue_condition\n",
    "        \n",
    "    except ValueError as error:\n",
    "        print(error)\n",
    "    \n",
    "ratio_bouts_pvalues"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bonferroni Correction\n",
      "---------------------\n",
      "\n",
      "\tOriginal Values:\n",
      " {'gal4_control': 0.08629421234185297, 'uas_control': 0.20526516919739457}\n",
      "\n",
      "\tCorrected Values:\n",
      " {'gal4_control': 0.17258842468370594, 'uas_control': 0.41053033839478914} \n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Bonferroni corretction for multiple comparisons.\n",
    "title = 'Bonferroni Correction'\n",
    "print(title)\n",
    "print('-'*len(title))\n",
    "\n",
    "# Show uncorrected values.\n",
    "print('\\n\\tOriginal Values:\\n', ratio_bouts_pvalues)\n",
    "\n",
    "# Apply the bonferroni correction for multiple comparisons.\n",
    "ratio_bouts_multi_comp_correction = multipletests(pvals=list(ratio_bouts_pvalues.values()), alpha=0.05, method='bonferroni')[1]\n",
    "\n",
    "# Transform the correction results into a dictionary.\n",
    "corrected_ratio_bouts_pvalues = dict(zip(list(ratio_bouts_pvalues.keys()), ratio_bouts_multi_comp_correction))\n",
    "\n",
    "# Show corrected values.\n",
    "print('\\n\\tCorrected Values:\\n', corrected_ratio_bouts_pvalues, '\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Effect Size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gal4_control\n",
      "Large Efect: 1.0 \n",
      "\n",
      "uas_control\n",
      "Vestigial Effect: 0.142857142857143 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'gal4_control': 1.0, 'uas_control': 0.142857142857143}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratio_bouts_sizes = {}\n",
    "\n",
    "test = ratio_bouts_df.query('condition==\"test\"')['ratio_bouts']\n",
    "\n",
    "for condition in condition_order[:-1]:\n",
    "\n",
    "    print(condition)\n",
    "    \n",
    "    control = ratio_bouts_df.query('condition==\"' + condition + '\"')['ratio_bouts']\n",
    "\n",
    "    median_diff = helpers.get_effect_size(control, test, method='median_diff')\n",
    "    \n",
    "    ratio_bouts_sizes[condition] = median_diff\n",
    "    \n",
    "ratio_bouts_sizes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAEgCAYAAACU1c66AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4n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Of2Gz0Zq20Wc6gtGsrKyEBsbCx8fH4waNQrZ2dmGn33yySeIi4uDn58fFi5ciNLSUkRGRpp8rz179mDZsmVYsmQJXn755U7bVFZWIisrC4WFhc/9d3meXrTtIgq/C71ximp3bG0f/5OTNHyWPXTokGEaaVJSktE00rlz56Kurg6bN2+Gg4MD5s6di2XLlplcl1KpREFBAVatWoWamppO2wwePLjbr6BaguS2i1nOI14wL9Kp/r179+jq6mq0rK6ujgMHDmRpaSltbW05dOhQent708vLi7a2tiwpKeHly5e5YcMGo9dVVlbSycmJJA1TVuVyOcn2U9qHU1Y//PBDRkVFUafTkTQ+pe1uhpqlSG27iCO+xPTt2xd+fn7Izc01LPvss88QExODgwcPYuHChaipqUF1dTVUKhXmzJmDffv2YdCgQdi5cyd++OEHw+vOnTuH8PBwAEBZWZnh8ZBMJgMAfPTRR2hpaXnsq6Q9ieS2i1l3K0KPVFlZyejoaI4YMYIBAQFMTExkfX093dzcWF5ebtT2/Pnz7NOnDxsaGnjy5Em+8cYbfPXVV+nv78+4uDjW1NR0uo6Oo9ckeenSJTo7O/P48eM98ohPSmu7iAk8giBB4lRfECRIFL4gSJAofEGQIFH4giBBovAFQYJE4QuCBInCFwQJEoUvCBIkCl8QJEgUviBI0P8D5Qp7+n0sEgIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 270x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Initialize figure.\n",
    "n_conditions = ratio_bouts_df['condition'].nunique()\n",
    "figure, axis = plt.subplots(figsize=(1.25*n_conditions, 4))\n",
    "\n",
    "# Draw the boxplot.\n",
    "sns.boxplot(x='condition',\n",
    "            y='ratio_bouts',\n",
    "            data=ratio_bouts_df,\n",
    "            order=condition_order,\n",
    "            width=0.6,\n",
    "            showfliers=False,\n",
    "            palette=['#f3c053', '#f3c053', '#ff5714'],\n",
    "            boxprops={'edgecolor': INK},\n",
    "            medianprops={'color': INK},\n",
    "            whiskerprops={'color': INK},\n",
    "            capprops={'color': INK}\n",
    "           )\n",
    "\n",
    "# Draw the swarmplot.\n",
    "sns.swarmplot(x='condition',\n",
    "              y='ratio_bouts',\n",
    "              data=ratio_bouts_df,\n",
    "              order=condition_order,\n",
    "              palette=['#f3c053', '#f3c053', '#ff5714'],\n",
    "              linewidth=0.75,\n",
    "              edgecolor=INK\n",
    "             )\n",
    "\n",
    "# Figure and axes formatting.\n",
    "axis.set_xlabel('')\n",
    "axis.set_xticklabels([''])\n",
    "axis.set_ylabel('# Bouts / Minute of Copulation')\n",
    "axis.set_ylim(0, 8)\n",
    "axis.set_yticks(np.arange(0, 8+1, 1))\n",
    "axis.set_yticklabels([round(label, 1) for label in axis.get_yticks()])\n",
    "\n",
    "# Table definition.\n",
    "row1 = [str(ratio_bouts_df.query('condition==\"'+condition+'\"').shape[0]) for condition in condition_order]\n",
    "row2 = ['IR84a-GAL4;\\n+', '+;\\nUAS-Kir', 'IR84a-GAL4;\\nUAS-Kir']\n",
    "cell_text = np.array([row1, row2])\n",
    "\n",
    "row_labels = ['n =', '']\n",
    "summary_table = axis.table(cellText= cell_text,\n",
    "                           cellLoc='center',\n",
    "                           rowLabels=row_labels,\n",
    "                           rowLoc='center',\n",
    "                           colLoc='center'\n",
    "                          )\n",
    "\n",
    "summary_table.auto_set_font_size(False)\n",
    "summary_table.set_fontsize(11)\n",
    "\n",
    "properties = summary_table.properties()\n",
    "table_cells = properties['children']\n",
    "for cell in table_cells:\n",
    "    cell.set_height(0.12)\n",
    "    cell.set_alpha(0)\n",
    "\n",
    "# Draw statistical results.\n",
    "for p, condition in enumerate(condition_order[:-1]):\n",
    "    sig_height = 6 if (corrected_ratio_bouts_pvalues.get(condition, 'NaN') == 'NaN') or (corrected_ratio_bouts_pvalues.get(condition, 'NaN') >= 0.05) else 2\n",
    "    helpers.plot_stattest_result(ax=axis,\n",
    "                                 x1=p,\n",
    "                                 x2=p,\n",
    "                                 p_value=corrected_ratio_bouts_pvalues.get(condition, 'NaN'),\n",
    "                                 y=7.5,\n",
    "                                 ticksize=0,\n",
    "                                 xytext=(0,sig_height),\n",
    "                                 fontsize=13,\n",
    "                                 color=INK,\n",
    "                                 connector_color=INK\n",
    "                                )\n",
    "\n",
    "# Saving parameters.\n",
    "filename = 'nbouts_aggression_normalized_5mins_Ir84a'\n",
    "plt.savefig(os.path.join(savepath, filename))\n",
    "\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
